package com.example.administrator.pomelostreet.HttpUtils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/2/14.
 */

public class FoodFragmentParseJson {
    public static List<FoodFragmentBeen> ParseJson(String path){
        try {
            JSONObject jsonObject=new JSONObject(path);
            JSONObject data = jsonObject.getJSONObject("data");
            JSONArray item_list = data.getJSONArray("item_list");
            List<FoodFragmentBeen> arrs=new ArrayList<>();
            for (int i=0;i<item_list.length();i++){
                JSONObject jsonObject1 = item_list.getJSONObject(i);
                FoodFragmentBeen foodfragmentbeen=new FoodFragmentBeen();
                foodfragmentbeen.setName(jsonObject1.getString("name"));
                foodfragmentbeen.setOriginal_price(jsonObject1.getString("original_price"));
                foodfragmentbeen.setPicture(jsonObject1.getString("picture"));
                foodfragmentbeen.setVip_price(jsonObject1.getString("vip_price"));
                foodfragmentbeen.setPurchase_btn(jsonObject1.getString("purchase_btn"));
              arrs.add(foodfragmentbeen);
            }
            return arrs;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }


}
